package com.hnqcgc.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MyConn implements IDB{
    private String url="jdbc:mysql://localhost:3306/dujiaoshou?" +
            "useSSL=false&serverTimezone=Hongkong&" +
            "characterEncoding=utf-8&autoReconnect=true";
    //加载驱动
    public MyConn() {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    @Override
    public Connection getConn() throws SQLException {
        Connection conn =
                DriverManager.getConnection(url, "root", "123456");
        return conn;
    }


    public static void main(String[] args) {
        try {
            Connection conn = new MyConn().getConn();
            System.out.println(conn.isClosed());
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
